<!DOCTYPE html>
<html>
<head>
    <title>文章信息表</title>
    <#include "/header.html">
<!--    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">-->
<!--    <link rel="stylesheet" href="${request.contextPath}/statics/element-ui/element-ui.2.15.0.css">-->
    <!-- 引入组件库 -->
<!--    <script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>-->
<!--    <script src="${request.contextPath}/statics/element-ui/element-ui.2.15.0.js"></script>-->
    <script src="${request.contextPath}/statics/libs/layer.js"></script>
    <script src="${request.contextPath}/statics/js/modules/sys//bese64.js"></script>
<!--    <script src="../../../statics/js/modules/sys/bese64.js"></script>-->
    <!--<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />-->
    <!--    <script type="text/javascript"  src="http://code.jquery.com/jquery-2.2.4.js"></script>-->
    <!--    <script type="text/javascript"  src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>-->
</head>
<body>
<style>
    th{
        text-align: center;
    }
    td {
        text-align: center;
    }
    .layui-layer-prompt .layui-layer-input {
        width: 400px;
    }
</style>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <div style="float: left">
                <input style="width: 100px" type="text" class="form-control" v-model="q.id" @keyup.enter="query" placeholder="文章id">
            </div>
            <p style="float: left">&nbsp;</p>
            <div style="float: left">
                <input style="width: 200px" type="text" class="form-control" v-model="q.articleTitle" @keyup.enter="query" placeholder="标题">
            </div>
            <p style="float: left">&nbsp;</p>
            <div style="float: left">
                <input style="width: 100px" class="form-control" list="brandName" placeholder="品牌" id="brandNames">
                <datalist id="brandName" style="line-height: 10px">

                </datalist>
            </div>
            <p style="float: left">&nbsp;</p>
            <div style="float: left">
                <input style="width: 100px" class="form-control" list="source" placeholder="来源筛选" id="articleSource">
                <datalist style="line-height: 10px" id="source">
                    <option>管理员</option>
                    <option>用户</option>
                    <option>V名片</option>
                    <option>公众号</option>
                    <option>入库</option>
                </datalist>
            </div>
            <p style="float: left">&nbsp;</p>
            <div style="float: left">
                <select style="height: 34px;" id="articleStatusList" v-model="q.articleStatus">
                    <option value="" >全部</option>
                    <option value="0">删除</option>
                    <option value="1">正常</option>
                    <option value="2">隐藏</option>
                </select>
            </div>
            <!--<p style="float: left">&nbsp;</p>-->
            <!--<div style="float: left">-->
                <!--<select class="form-control" id="desc" style="width: 120px">-->
                    <!--<option value="">排序方式</option>-->
                    <!--<option value="1">创建时间</option>-->
                    <!--<option value="2">分享次数</option>-->
                    <!--<option value="3">查看次数</option>-->
                <!--</select>-->
            <!--</div>-->
            &nbsp;&nbsp;&nbsp;
            <a class="btn btn-default" @click="query">查询</a>
			<!--<#if shiro.hasPermission("sys:barticleinfo:save")>-->
            <!--<a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>-->
			<!--</#if>-->
			<!--<#if shiro.hasPermission("sys:barticleinfo:update")>-->
            <!--<a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>-->
			<!--</#if>-->
            <#if shiro.hasPermission("sys:barticleinfo:update")>
            <a class="btn btn-primary" @click="status('2')">&nbsp;隐藏</a>
            </#if>
			<!--<#if shiro.hasPermission("sys:barticleinfo:update")>-->
            <!--<a class="btn btn-primary" @click="updateStatus('0')"><i class="fa fa-pencil-square-o"></i>&nbsp;删除</a>-->
			<!--</#if>-->
            <!--<#if shiro.hasPermission("sys:barticleinfo:update")>-->
            <!--<a class="btn btn-primary" @click="updateStatus('1')"><i class="fa fa-pencil-square-o"></i>&nbsp;恢复</a>-->
            <!--</#if>-->
            <!--<#if shiro.hasPermission("sys:barticleinfo:update")>-->
            <!--<a class="btn btn-primary" @click="updateStatus('3')"><i class="fa fa-pencil-square-o"></i>&nbsp;设为热门</a>-->
            <!--</#if>-->
            <a class="btn btn-default" onclick="vm.mergeBtn()"><i class="fa fa-plus"></i>&nbsp;复制文章</a>
<!--        <input @click="openGetWeiXinPage" type="button" value="抓取微信文章" class="btn btn-primary">-->
            <a class="btn btn-primary" onclick="addArticle()"><i class="fa fa-plus"></i>&nbsp;生成文章</a>
            <a class="btn btn-primary" onclick="vm.addInfo(0,1)"><i class="fa fa-plus"></i>&nbsp;创建文章</a>
            <!--<a class="btn btn-primary" @click="importArticle1" title="导入爬虫文章."><i class="fa fa-plus"></i>&nbsp;导入文章</a>-->
            <a class="btn btn-primary" onclick="addArticle2()" style="display: none"><i class="fa fa-plus"></i>&nbsp;生成早安新闻</a>
        </div>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>
    <div v-show="!hebing" id="hebing" style="text-align:center">
        <table style="margin: auto;text-align:center;border-collapse:separate; border-spacing:0px 20px;position: center">
            <tr>
                <td>
                    <!--<input style="width: 120px" class="form-control" list="brandNameList" placeholder="品牌" id="merge"
                           onblur="vm.getValue(this)">
                    <datalist id="brandNameList">

                    </datalist>-->
                    <input style="width: 120px" class="form-control" list="allArticleTypeNames" placeholder="行业" id="merge"
                           onblur="vm.getValue(this)">
                    <datalist id="allArticleTypeNames">

                    </datalist>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" class="btn btn-primary" onclick="vm.mergeOk()" value="确定"/>
                </td>
            </tr>
        </table>
    </div>
    <div v-show="!showList" class="panel panel-default">
        <div class="panel-heading">{{title}}</div>
        <form class="form-horizontal">
                    <div class="form-group">
                        <div class="col-sm-2 control-label">文章名称</div>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" v-model="bArticleInfo.articleTitle" placeholder="文章名称"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-2 control-label">文章类型</div>
                        <div class="col-sm-10">
                            <select class="form-control input-sm" id="type">

                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-2 control-label">文章内容</div>
                        <div class="col-sm-10">
                            <textarea style="width: 100%;height: 80px" class="form-control">
                                {{bArticleInfo.articleContent}}
                            </textarea>
                        </div>
                    </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">文章描述</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="bArticleInfo.articleDesc" placeholder="文章描述"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label"></div>
                <input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
                &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
            </div>
        </form>
    </div>
</div>
<!-- bootstrap 模态框 -->
<#include "/modules/sys/barticleinfo_common.html">
<script>
    function addArticle() {
        // var brandName=$("#brandNames").val()
        // window.open("../sys/webspider.html?");
        var resultId= 0;
        //prompt层
        layer.prompt({title: '请把文章链接粘贴到输入框，并确认', formType: 0, area: ['1200px', '1000px']}, function(text, index){

            var loading = layer.msg('文章拼命生成中，别催我...',{icon:16,shade:0.3,time:0});
            console.info("text：" + text);

            if (text == null || text == '') {
                return false;
            }
            var url = "sys/bvideoinfo/getWeiXinPage";

            $.ajax({
                type: "POST",
                url: baseURL + url,
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(text),
                dataType: "JSON",
                success: function (r) {
                    layer.close(loading);
                    layer.close(index);
                    if (r.code === 0) {
                        resultId = r.resultId
                        alert('生成文章成功，去浏览...', function(index){
                            if(resultId>0){
                                window.open('./modules/sys/barticle_edit.html?id=' + resultId);
                            }
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        });
        //
        // if(resultId>0){
        //     window.open('./modules/sys/barticle_edit.html?id=' + resultId);
        // }
    }

    function addArticle2() {
        // var brandName=$("#brandNames").val()
        // window.open("../sys/webspider.html?");
        var resultId= 0;
        //prompt层
        layer.prompt({title: '请把文章链接粘贴到输入框，并确认', formType: 0, area: ['1200px', '1000px']}, function(text, index){

            var loading = layer.msg('文章拼命生成中，别催我...',{icon:16,shade:0.3,time:0});
            console.info("text：" + text);

            if (text == null || text == '') {
                return false;
            }
            var url = "sys/bvideoinfo/getWeiXinPage2";

            $.ajax({
                type: "POST",
                url: baseURL + url,
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(text),
                dataType: "JSON",
                success: function (r) {
                    layer.close(loading);
                    layer.close(index);
                    if (r.code === 0) {
                        resultId = r.resultId
                        alert('生成文章成功，去浏览...', function(index){
                            if(resultId>0){
                                vm.query();
                            }
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        });
        //
        // if(resultId>0){
        //     window.open('./modules/sys/barticle_edit.html?id=' + resultId);
        // }
    }

    // setTimeout(function () {
    //     $.ajax({
    //         type: "POST",
    //         async:false,
    //         url: baseURL + 'sys/bbrandinfo/queryAll',
    //         contentType: "application/json",
    //         success: function(r){
    //             // console.log(r);
    //             if(r.code==0){
    //                 for(var i=0;i<r.brandInfo.length;i++){
    //                     $("#brandNameList").append(
    //                         "<option value=" + r.brandInfo[i].brandName +">"+"</option>");
    //                 }
    //             }
    //         }
    //     });
    // },2000);
</script>
<script src="${request.contextPath}/statics/js/modules/sys/barticleinfo_common.js?_${.now?long}"></script>
<script src="${request.contextPath}/statics/js/modules/sys/barticleinfo.js?_${.now?long}"></script>
</body>
</html>
